<template>
	<view>
		<view class="top">
			<image src="@/static/admin/detailBg.png" mode="widthFix"></image>
			<view class="info">
				<image :src="info.avatar" mode=""></image>
				<view class="name">
					{{info.nickname}}
				</view>
			</view>
			<view class="wrap">
				<view class="score">
					<image src="@/static/admin/icon/icon.png" mode=""></image>
					<view class="text">
						TA的积分
						<view class="num">
							{{info.score}}
						</view>
					</view>
				</view>
				<view class="list">
					<view class="col" v-for="item in list" :key="item.id">
						<view class="left">
							<image v-if="item.score>0" src="@/static/admin/icon/icon3.png" mode=""></image>
							<image v-else src="@/static/admin/icon/icon4.png" mode=""></image>
							<view class="text">
								<view class="time">
									<uni-dateformat :date="item.createtime*1000"></uni-dateformat>
								</view>
								{{item.memo}}
							</view>
						</view>
						<view class="right" :class="{'bonus':item.score>0}">
							<text v-if="item.score>0">+</text>
							{{item.score}}
							<image v-if="item.score<0" src="@/static/admin/icon/icon1.png" mode=""></image>
							<image v-else src="@/static/admin/icon/icon2.png" mode=""></image>
						</view>
					</view>
				</view>
				<uni-load-more :status="status"></uni-load-more>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				info: {
					nickname: '',
					score: ''
				},
				work_no: '',
				status: "no-more",
				user_id: '',
				list: []
			}
		},
		onLoad(option) {
			this.work_no = option.work_no
		},
		onShow() {
			this.getInfo()
		},
		onPullDownRefresh() {
			this.init()
		},
		onReachBottom() {
			this.page++
			this.getList()
		},
		methods: {
			getInfo() {
				this.$post("/worker/worker", {
					work_no: this.work_no
				}).then(res => {
					this.info = res.data
					this.user_id = res.data.user_id
					this.init()
				})
			},
			init() {
				this.list = []
				this.page = 1
				this.getList()
			},
			getList() {
				this.status = "loading"
				this.$post("/user/score", {
					page: this.page,
					user_id: this.user_id
				}).then(res => {
					this.status = "no-more"
					uni.stopPullDownRefresh()
					this.list = this.list.concat(res.data.data)
				})
			}
		}
	}
</script>

<style lang="scss">
	.top {
		position: relative;
		height: 400rpx;

		.bg {
			width: 100%;
			height: 400rpx;
		}

		.info {
			position: absolute;
			left: 50%;
			top: 45%;
			transform: translate(-50%, -50%);

			image {
				width: 128rpx;
				height: 128rpx;
				border-radius: 50%;
				border: 6rpx solid #fff;

			}

			.name {
				color: #fff;
				font-size: 34rpx;
				margin-top: 20rpx;
				text-align: center;
			}
		}
	}

	.score {
		background: #FFFFFF;
		box-shadow: 0rpx 0rpx 16rpx 4rpx rgba(0, 0, 0, 0.1);
		border-radius: 20rpx;
		display: flex;
		align-items: center;
		padding: 30rpx;
		font-size: 28rpx;
		transform: translateY(-60rpx);


		image {
			width: 88rpx;
			height: 88rpx;
			margin-right: 20rpx;
		}

		.num {
			font-size: 48rpx;
			color: #FF5B5B;
			margin-top: 10rpx;
		}
	}

	.list {
		.col {
			padding: 20rpx 0;
			border-bottom: 1rpx solid #eee;
			display: flex;
			align-items: center;
			justify-content: space-between;

			.left {
				display: flex;
				align-items: center;
				width: calc(100% - 160rpx);

				image {
					width: 76rpx;
					height: 76rpx;
				}

				.text {
					width: calc(100% - 76rpx);
					padding: 0 20rpx;
					font-size: 30rpx;

					.time {
						font-size: 24rpx;
						color: #7d7d7d;
						margin-bottom: 10rpx;
					}
				}
			}

			.right {
				max-width: 160rpx;
				color: #1BAFAA;
				font-size: 36rpx;
				text-align: right;

				&.bonus {
					color: #3670F6;
				}

				image {
					width: 30rpx;
					height: 30rpx;
					margin-left: 20rpx;
				}
			}
		}
	}
</style>